Skip to content

Fix incorrect per-numa-cell allocation reporting - #106

Merged
PhilippMatthes merged 1 commit into
mainfrom
fix/per-numa-cell-allocation-reporting
Nov 6, 2026
Merged

PhilippMatthes merged 1 commit into
mainfrom
fix/per-numa-cell-allocation-reporting

Conversation

@PhilippMatthes

Copy link
Copy Markdown
Member

hypervisor.status.cells reported per-NUMA-cell memory and CPU allocation keyed by each domain's guest NUMA cell id (the memnode cellid and cpu numa cell id), which is a per-VM virtual index that is almost always 0 for single-vNUMA VMs; this concentrated nearly all allocation on host cell 0 regardless of which host physical NUMA node the VMs were actually pinned to, and only VMs spanning multiple vNUMA nodes showed multi-cell allocation. This change keys the accounting by the host physical NUMA node taken from the memnode nodeset instead, resolves each guest CPU NUMA cell to its host node through the same guest-cell-to-host-node mapping so CPU and memory are attributed consistently, adds a parseSingleNodeset helper that rejects nodesets spanning more than one host node, and adds regression tests covering a single-vNUMA VM pinned to a non-zero host cell as well as a multi-cell VM whose guest cell ids differ from its host nodes.

addAllocationCapacity keyed per-cell memory and CPU accounting by the
domain's guest NUMA cell id (memnode cellid / cpu numa cell id), which is
a per-VM virtual index and almost always 0 for single-vNUMA VMs. As a
result, nearly all allocation was attributed to host cell 0 regardless of
which host physical NUMA node the VMs were actually pinned to; only VMs
spanning multiple vNUMA nodes showed multi-cell allocation.

Key the accounting by the host physical NUMA node from the memnode
nodeset instead, and resolve each guest CPU NUMA cell to its host node
via the same guest-cell-to-host-node mapping so CPU and memory are
attributed consistently. Add parseSingleNodeset to parse the nodeset and
reject multi-node sets that cannot be attributed to a single cell.

Co-authored-by: jeoff.zheng@sap.com <jeoff.zheng@sap.com>
Signed-off-by: Philipp Matthes <p.matthes@sap.com>
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/cobaltcore-dev/kvm-node-agent/internal/libvirt 46.84% (+1.72%) 👍
Coverage details

Compared to commit fb5169a (run #41906518979)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/cobaltcore-dev/kvm-node-agent/internal/libvirt/libvirt.go 74.17% (+0.25%) 240 (+10) 178 (+8) 62 (+2) 👍
github.com/cobaltcore-dev/kvm-node-agent/internal/libvirt/utils.go 62.96% (+7.41%) 54 (+9) 34 (+9) 20 👍

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files:

  • github.com/cobaltcore-dev/kvm-node-agent/internal/libvirt/libvirt_test.go
  • github.com/cobaltcore-dev/kvm-node-agent/internal/libvirt/utils_test.go

@PhilippMatthes
PhilippMatthes merged commit 72fee47 into main Nov 6, 2026
9 checks passed
@PhilippMatthes
PhilippMatthes deleted the fix/per-numa-cell-allocation-reporting branch November 6, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants